package org.or5e.odes.core;

import java.io.IOException;
import java.util.Properties;

import org.apache.log4j.Logger;

public abstract class BaseObject {
	private Logger _logger = null;
	private static Properties _baseprops = null;
	static {
		_baseprops = new Properties();
		try {
			_baseprops.loadFromXML(ClassLoader.getSystemResourceAsStream("config/app-config.xml"));
		} catch (IOException e) {
			e.printStackTrace(System.out);
		}
		
	}
	public BaseObject() {
		_logger = Logger.getLogger(getName());
	}
	protected void info(Object message) {
		_logger.info(message);
	}
	protected void debug(Object message) {
		_logger.debug(message);
	}
	protected void warn(Object message) {
		_logger.warn(message);
	}
	protected void error(Object message) {
		_logger.error(message);
	}
	protected String getProperty(String key) {
		return BaseObject._baseprops.getProperty(key);
	}
	protected abstract String getName();
	
	public static void main(String[] args) {
		BaseObject bo = new BaseObject() {
			@Override protected String getName() {
				return "BaseObject";
			}
		};
		bo.info("Display Info message");
		bo.debug("Display Debug message");
		bo.warn("Display Warn message");
		bo.error("Display error message");
	}
}